package com.sgzn.sgpay.web.controller;

import com.sgzn.sgpay.model.request.SgsShowIncomeRecordRequest;
import com.sgzn.sgpay.model.response.SgsResultResponse;
import com.sgzn.sgpay.model.response.vo.ShowIncomeRecordVo;
import com.sgzn.sgpay.service.SgsShowIncomeRecordService;
import com.sgzn.sgpay.web.controller.base.MerchantBaseController;
import com.sgzn.sgpay.web.handle.AssembleCommonHandle;
import com.sgzn.sgpay.web.request.Impl.ShowIncomeRecordRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 首页收益统计控制器
 * @author huangsenguang
 * @version Id: ShowIncomeRecordController.java, v 0.1 2018/6/13 13:11 huangsenguang Exp $$
 */
@Slf4j
@Controller
public class ShowIncomeRecordController extends MerchantBaseController {
    @Resource
    private SgsShowIncomeRecordService sgsShowIncomeRecordService;
    @Resource
    private AssembleCommonHandle assembleCommonHandle;
    /**
     * 首页收益统计查询
     * @param request
     * @return
     */
    @RequestMapping("/merchant/income/head")
    @ResponseBody
    public SgsResultResponse<ShowIncomeRecordVo> queryIncomePreInfo(ShowIncomeRecordRequest request) {
        super.setMchInfo(request);
        return this.sgsShowIncomeRecordService.query(assembleRequest(request));
    }

    private SgsShowIncomeRecordRequest assembleRequest(ShowIncomeRecordRequest request) {
        SgsShowIncomeRecordRequest sgsShowIncomeRecordRequest = new SgsShowIncomeRecordRequest();
        this.assembleCommonHandle.assemble(request, sgsShowIncomeRecordRequest);
        return sgsShowIncomeRecordRequest;
    }
}

